package ThreadPool.lagou.concurrent.countDownLatch.demo01;

import java.util.concurrent.CountDownLatch;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description: 自定义线程
 * @date 2022/10/5 15:27
 */
public class MyThread extends Thread{

    private final CountDownLatch latch;

    public MyThread(String name, CountDownLatch latch) {
        super(name);
        this.latch = latch;
    }

    @Override
    public void run() {
        try {
            sleep(500);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(Thread.currentThread().getName()+"执行完毕");
        // 计数器减一
        latch.countDown();
    }
}
